package it.abc.sicsic.view.backing.barche;

import it.abc.sicsic.JavaServiceFacade;
import it.abc.sicsic.model.barche.Barche;
import it.abc.sicsic.view.backing.NauticaTemplate;
import it.abc.sicsic.view.util.ViewUtil;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;

import oracle.adf.view.rich.component.rich.output.RichOutputText;

import org.apache.log4j.Logger;

@ManagedBean(name = "backing_gestioneBarche")
@SessionScoped

public class GestioneBarche {
    private RichForm f1;
    private RichDocument d1;
    private RichTable tableBarche;

    private RichInputText itNomeBarca;
    private RichInputText itModello;
    private static Logger logger = Logger.getLogger(GestioneBarche.class);

    public GestioneBarche(){

        
    }

    public void setF1(RichForm f1) {
        this.f1 = f1;
    }

    public RichForm getF1() {
        return f1;
    }

    public void setD1(RichDocument d1) {
        this.d1 = d1;
    }

    public RichDocument getD1() {
        return d1;
    }

    public void setTableBarche(RichTable tableBarche) {
        this.tableBarche = tableBarche;
    }

    public RichTable getTableBarche() {
        return tableBarche;
    }





    public void setItNomeBarca(RichInputText itNomeBarca) {
        this.itNomeBarca = itNomeBarca;
    }

    public RichInputText getItNomeBarca() {
        return itNomeBarca;
    }

    public void setItModello(RichInputText itModello) {
        this.itModello = itModello;
    }

    public RichInputText getItModello() {
        return itModello;
    }
    
    private String getNomeBarca(){
        return ViewUtil.getStringValue(getItNomeBarca());
    }
    private String getModello(){
        return ViewUtil.getStringValue(getItModello());
    }

    public void cerca2(ActionEvent actionEvent) {
        logger.info("cerca GestioneBarche start");

        JavaServiceFacade serviceFacade = new JavaServiceFacade();
        List<Barche> list = null;
        list = serviceFacade.getBarche(getNomeBarca(),getModello());        
        tableBarche.setValue(list);
        System.out.println("cerca GestioneBarche start");
    }
}
